home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / BLWCB15A.ZIP / BLW-CBC.PAS < prev    next >
Pascal/Delphi Source File  |  1996-08-27  |  4KB  |  90 lines

  1. program BlowFish_CBC_Example;
  2.  
  3.   {*****************************************************************}
  4.   {*******  BLW-CBC.pas (c) 1996 by Dutra Lacerda <2:362/20> *******}
  5.   {*******   E-Mail address:  dutra.lacerda@mail.telepac.pt  *******}
  6.   {*******     Compuserve  :  100342,2501  (a month delay)   *******}
  7.   {*******  Example program of the usage of the BLW_CBC Unit *******}
  8.   {*******        Hereby donated to the public domain        *******}
  9.   {*****************************************************************}
  10.  
  11. uses Dos, BfishCBC;
  12.  
  13. {$M $A000,0,$28000}
  14.  
  15. var
  16.   Key : String;
  17.   InputFile,
  18.   OutputFile : String;
  19.   Choice : String[3];
  20.   Input,
  21.   Output : file;
  22.   Hour,
  23.   Minute,
  24.   Second,
  25.   Second100 : Word;
  26.  
  27.  
  28.   function File_Exists(const FileName : String) : Boolean;
  29.   var
  30.     F : file;
  31.  
  32.   begin
  33.     Assign(F, FileName);
  34.         {$i-} Reset(F, 1); {$i+}
  35.     File_Exists := IoResult = 0;
  36.   end;
  37.  
  38.  
  39. begin
  40.   WriteLn;
  41.   WriteLn(#9, ':::::::::::::: Blowfish-CBC CRYPT-Utility v1.5.A ::::::::::::::');
  42.   WriteLn(#9, '::  Public Domain by: Dutra Lacerda, MediSis BBS <2:362/20>  ::');
  43.   WriteLn(#9, '::  Email: dutra.lacerda@mail.telepac.pt / CIS: 100342,2501  ::');
  44.   WriteLn(#9, ':::::::::::: PROTECTS your FILES, and your PRIVACY ::::::::::::');
  45.   Choice := Copy(ParamStr(1), 1, 3);
  46.   Choice[1] := Upcase(Choice[1]);
  47.   InputFile := ParamStr(3);
  48.   OutputFile := ParamStr(4);
  49.   if ((Choice = 'E') or (Choice = 'D')) and
  50.   (ParamStr(2) <> '') and
  51.   (ParamStr(3) <> '') then
  52.     begin
  53.       if File_Exists(ParamStr(3)) then
  54.         begin
  55.           Key := Copy(ParamStr(2), 1, 56);
  56.           WriteLn(#13, #10, 'Initializing key');
  57.           BLW_CBC_INIT(Key, 8);
  58.           GetTime(Hour, Minute, Second, Second100);
  59.           WriteLn(Hour, ':', Minute, ':', Second, ':', Second100);
  60.  
  61.           if Choice = 'E' then
  62.             BLW_CBC_CRYPT(InputFile, OutputFile)
  63.           else
  64.             BLW_CBC_DECRYPT(InputFile, OutputFile);
  65.  
  66.           GetTime(Hour, Minute, Second, Second100);
  67.           WriteLn(#13, #10, Hour, ':', Minute, ':', Second, ':', Second100);
  68.         end {If 3th Argument (a File) exists}
  69.       else {If 3th Argument (a File) does not exists}
  70.         Writeln(#13, #10, 'File ',ParamStr(3),' does not exist! Aborting...');
  71.     end {IF-else there Are 3 Arguments}
  72.   else
  73.     begin
  74.       WriteLn;
  75.       WriteLn(#9, '╒═════════════════════════════════════════════════════════════╕');
  76.       WriteLn(#9, '│ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  BlowFish-CBC 1.5 Help  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │');
  77.       WriteLn(#9, '├─────────────────────────────────────────────────────────────┤');
  78.       WriteLn(#9, '│     BLW-CBC (E|D) <PassFrase> <InputFile> [<OutputFile>]    │');
  79.       WriteLn(#9, '│              │ │                   |             |          │');
  80.       WriteLn(#9, '│   Encrypt ───┘ └─── Decrypt     Origin!   Optional Argument │');
  81.       WriteLn(#9, '├─────────────────────────────────────────────────────────────┤');
  82.       WriteLn(#9, '│ For Best Protection Use LONG PassFrases, with ''_'' as spaces │');
  83.       WriteLn(#9, '╘═════════════════════════════════════════════════════════════╛');
  84.       Writeln(#9, '                                                               ');
  85.       Writeln(#9, '    Example          Mode       Frase        File              ');
  86.       Writeln(#9, '    ~~~~~~~           |           |            |               ');
  87.       Writeln(#9, ' C:\SECRET>  BLW-CBC  E  MyOwn_Secret_Key  myfile.txt  <Enter> ');
  88.     end;
  89. end.
  90.